﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>

<?php	

	include("inc/joomlaInt.php");
	include("inc/inc_configuration.php");

if ($jUser==0)
{
	echo "Bitte zuerst einloggen!";
}
else
{
	$q = "	SELECT 
				u.id AS uid,
				a.start,
				a.end,
				a.reason,
				u.username
			FROM
				$tbl_abwesenheit a,
				$tbl_users u
			WHERE
				a.userId=u.id
			ORDER BY
				start DESC";
				
	$qe = mysql_query($q);
	$qec = mysql_num_rows($qe);
	
	if ($qec>0)
	{
		echo "	<table id='tabelle' width='650'>
					<thead>
					<tr>
						<th>User</th>
						<th>Teams</th>
						<th>Grund</th>
						<th>Von</th>
						<th>Bis</th>
					</tr>
					</thead>
					<tbody>
					
					";
		
		while ($row=mysql_fetch_object($qe))
		{
			$sd=$row->start;
			$ed=$row->end;
			$s=date("d.m.Y",$sd);
			$e=date("d.m.Y",$ed);
			$uid=$row->uid;
			
			$cQ = "SELECT teamId,name FROM $tbl_combinations c, $tbl_teams t WHERE c.userId=$uid AND c.active=1 AND c.teamId=t.id";
			$cQe = mysql_query($cQ);
			$canz = mySQL_num_rows($cQe);

			if ($canz>0)
			{
				$t1nO=mysql_fetch_object($cQe);
				$t1n=$t1nO->name;
				$t1i=$t1nO->teamId;
				
				$teams= "<a class='tooltip'><img src='img/logos/$t1i.png' width='35' height='35'><span>$t1n</span></a>";
				$twidth=40;
				
				if ($canz==2)
				{
					$t2nO=mysql_fetch_object($cQe);
					$t2n=$t2nO->name;
					$t2i=$t2nO->teamId;
					$twidth=75;
					$teams.= " <a class='tooltip'><img src='img/logos/$t2i.png' width='35' height='35'><span>$t2n</span></a>";
				}
			
			}
			
			echo "	<tr>
						<td width='70'>",$row->username,"</td>
						<td width='$twidth'>$teams</td>
						<td>",$row->reason,"</td>
						<td width='70'>$s</td>
						<td width='70'>$e</td>
					</tr>";
		}
		
		echo "</tbody></table>";
	}
	
	echo "<br><br>
			<center><a href='abwesenheit_eintragen.php' class='button anlegen'>Hinzufügen</a></center>
			<center><a href='javascript:window.history.back()' class='button zurueck'>Zurück</a></center>";
}			
?>

</body>
</html>